home *** CD-ROM | disk | FTP | other *** search
/ The Programmer Disk / The Programmer Disk (Microforum).iso / xpro / basic3 / pro5 / trigii.bas (.txt) < prev    next >
Encoding:
GW-BASIC  |  1990-04-12  |  2.7 KB  |  58 lines

  1. 100  REM TRIGONOMETRIC FUNCTIONS 
  2. 105  WIDTH 80
  3. 110  REM IBM BASIC
  4. 120  PI=3.14159:RAD=57.2958
  5. 130  DEF FNHYP(X,Y)=SQR(X^2+Y^2):                           REM FIND HYPOTENUSE
  6. 140  DEF FNHX(H,Y)=SQR(H^2-Y^2):          REM FIND SIDE X,HORIZONTAL
  7. 150  DEF FNVY(H,X)=SQR(H^2-X^2):                            REM FIND SIDE Y,VERTICAL
  8. 160  DEF FNANGL(A)=90-A:                                    REM FIND ANGLE A OR B
  9. 170  DEF FNX(H,A)=H*COS(A*(PI/180)):                        REM FIND SIDE X BY H & A
  10. 180  DEF FNY(H,A)=H*SIN(A*(PI/180)):                        REM FIND SIDE Y BY H & A
  11. 190  DEF FNB(X,Y)=(ATN(X/Y))*(180/PI):                      REM FIND A OR B BY X & Y
  12. 200  GOTO 250
  13. 210  PRINT STRING$(80,45):RETURN
  14. 220  CLS:FOR X=1 TO 10:PRINT:NEXT X:RETURN
  15. 230  PRINT:INPUT "Press >RETURN<  (Q to quit) ",R$:IF R$="Q" THEN 240 ELSE RETURN
  16. 240  GOSUB 220:GOSUB 210:PRINT TAB(33)"End.":GOSUB 210:RUN"FILES."
  17. 250  GOSUB 220:PRINT"Menu:":GOSUB 210:PRINT"Ratios for right triangles:":GOSUB 210
  18. 260  PRINT 1,"Find hypotenuse":PRINT 2,"Find horizontal side (X)"
  19. 270  PRINT 3,"Find vertical side (Y)":PRINT 4,"Find angles A and B"
  20. 280  PRINT 5,"Find two sides (X & Y) by hypotenuse & angle"
  21. 290  PRINT 6,"Find angles A and B by X and Y":GOSUB 210
  22. 300  PRINT 7,"Exit program":GOSUB 210
  23. 310  INPUT "Which?          ",WHICH:GOSUB 220
  24. 320  ON WHICH GOTO 330,380,430,480,520,600,240
  25. 330  PRINT"Find the length of the hypotenuse of a right triangle":GOSUB 210
  26. 340  INPUT "Enter the horizontal length (X)       ",X
  27. 350  INPUT "Enter the vertical length   (Y)       ",Y
  28. 360  X=FNHYP(X,Y):GOSUB 210
  29. 370  PRINT"The length of the hypotenuse is       ";X:GOSUB 230:GOTO 250
  30. 380  PRINT"Find the length of the horizontal side (X) of a right triangle":GOSUB 210
  31. 390  INPUT "Enter the vertical length   (Y)       ",Y
  32. 400  INPUT "Enter the diagonal length (hypotenuse)",H
  33. 410  X=FNHX(H,Y):GOSUB 210
  34. 420  PRINT"The horizontal length is              ";X:GOSUB 230:GOTO 250
  35. 430  PRINT"Find the length of the vertical side (Y) of a right triangle":GOSUB 210
  36. 440  INPUT "Enter the horizontal length (X)       ",X
  37. 450  INPUT "Enter the diagonal length (hypotenuse)",H
  38. 460  XX=FNVY(H,X):GOSUB 210
  39. 470  PRINT"The vertical length is                ";XX:GOSUB 230:GOTO 250
  40. 480  PRINT"Find the angle opposite side X or Y in a right triangle":GOSUB 210
  41. 490  INPUT "Enter degrees of one angle            ",A
  42. 500  X=FNANGL(A):GOSUB 210
  43. 510  PRINT"The other angle is ";X;" degrees":GOSUB 230:GOTO 250
  44. 520  PRINT"Find the two other sides by hypotenuse and the angle"
  45. 530  PRINT"between the hypotenuse and the horizontal side":GOSUB 210
  46. 540  INPUT "Enter length of hypotenuse            ",H
  47. 550  INPUT "Enter the degrees of the angle        ",A
  48. 560  X=FNX(H,A):GOSUB 210
  49. 570  XX=FNY(H,A)
  50. 580  PRINT"The horizontal length is               ";X
  51. 590  PRINT"The vertical side is                   ";XX:GOSUB 230:GOTO 250
  52. 600  PRINT"Find the degrees of two angles by sides X and Y":GOSUB 210
  53. 610  INPUT "Enter horizontal side (X)             ",X
  54. 620  INPUT "Enter vertical side   (Y)             ",Y
  55. 630  XX=FNB(X,Y):GOSUB 210
  56. 640  PRINT"Angle A (opposite X) is ";XX;" degrees":BB=90-XX
  57. 650  PRINT"Angle B (opposite Y) is ";BB;" degrees":GOSUB 230:GOTO 250
  58.